//服务层
const {getCarousel3,addCarousel3,getOne3,updateOne3,delCarousel3} = require('../dao/carouselDao');
module.exports.getCarousel2 = async ()=>{
    const crsarr = await getCarousel3();
    crsarr.sort((a,b)=>{
        return a.showorder - b.showorder;
    })
    return crsarr;
}


module.exports.getOne2 = async (_id) => {
    return await getOne3(_id);
}

module.exports.updateOne2 = async (crs)=>{
    const data = await updateOne3(crs);
    if(data.ok ==1){
        return true;
    }else{
        return false;
    }
    
}

module.exports.addCarousel2 = async (crs)=>{
    const data = await addCarousel3(crs);
    if (data._id) {
        return true;
    } else {
        return false;
    }
}

module.exports.delCarousel2 = async (_id)=>{
    const data = await delCarousel3(_id);
    if (data.deletedCount == 1) {
        return true;
    } else {
        return false;
    }
}
